package com.wef.demo.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.gfa4j.query.Page;
import com.gfa4j.query.QueryInfo;
import com.gfa4j.wef.common.action.CommonQueryAction;
import com.gfa4j.wef.struts.BaseAction;
import com.gfa4j.wef.struts.QueryHandle;

public class SubjectAction extends BaseAction {

	public ActionForward subjectQuery(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
		// 1.
		QueryInfo queryInfo = CommonQueryAction.getQueryInfo(request);
		// 2.
		Page page = (Page) QueryHandle.findByQuery(queryInfo);
		// 3.
		String jsonString = CommonQueryAction.page2JsonString(page, request,queryInfo);
		// 4.
		CommonQueryAction.outData2Page(jsonString, response);
		return null;
	}

	public ActionForward subjectCustomParam(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
		// 1.
		QueryInfo queryInfo = CommonQueryAction.getQueryInfo(request);
		// 2.
		Page page = (Page) QueryHandle.findByQuery(queryInfo);
		// 3.
		String jsonString = CommonQueryAction.page2JsonString(page, request,queryInfo);
		// 4.
		CommonQueryAction.outData2Page(jsonString, response);
		// 5.接收自定义的参数
		System.out.println("接收到的自定义参数：" + request.getParameter("customParamName"));
		System.out.println("接收到的自定义参数：" + request.getParameter("customParamName2"));
		return null;
	}
}
